import java.io.* ;
class ValidCardNumber
{
  public static void main (String [] args) 
  {
   // calls readDigits( ) to read the input data
  int [ ] digits = DigitsLib.readDigits( );
  while ((digits.length == 4) && (!DigitsLib.isZero(digits)))
  {
    // sends the number to the valid() method
    boolean testValid = valid(digits);
    // print the result
    if (testValid)
      { System.out.println("This number is valid."); }
    else
      { System.out.println("This number is invalid."); }
    digits = DigitsLib.readDigits( );
  }

  }
  private static boolean valid (int [ ] digits)  
  {
  // find the first 3 digits pf the last group
  int firstThree = digits[3] / 10;
  // find the last digit of the number
  int lastDigit = digits[3] % 10; 
  // find the sum of the first 15 digits
  int sum = DigitsLib.sumDigits (digits[0]) 
        + DigitsLib.sumDigits (digits[1]) 
       + DigitsLib.sumDigits (digits[2]) 
    + DigitsLib.sumDigits (firstThree);
  // determins the validity
  boolean valid = (sum % 10 == lastDigit);
  return valid;

  }
}
